package com.carorder.model;



import java.util.*;
import com.carorderdetail.model.*;

public class CarOrderService {

	private CarOrderVO_interface dao;

	public CarOrderService() {
		dao = new CarOrderDAO();
	}

	public CarOrderVO addCarOrder(CarOrderVO newVO, CarOrderDetailVO carOrderDetailVO) {

		CarOrderVO carOrderVO = null;
		if (newVO != null) {
			carOrderVO = new CarOrderVO();

			carOrderVO.setDriverPathId(newVO.getDriverPathId());
			carOrderVO.setTotalFee(newVO.getTotalFee());
			carOrderVO.setMemberId(newVO.getMemberId());
		}
		dao.insertWithDetail(carOrderVO, carOrderDetailVO);

		return carOrderVO;
	}

	public CarOrderVO updateCarOrder(String driverPathId, Integer totalFee, Integer status) {

		CarOrderVO carOrderVO = new CarOrderVO();

		carOrderVO.setDriverPathId(driverPathId);
		carOrderVO.setTotalFee(totalFee);
		dao.update(carOrderVO);

		return carOrderVO;
	}

	public void deleteCarOrder(String orderId) {
		dao.delete(orderId);
	}

	public CarOrderVO getOneCarOrder(String driverPathId) {
		return dao.findByPrimaryKey(driverPathId);
	}

	public List<CarOrderVO> getAll() {
		return dao.getAll();
	}
	
	public List<CarOrderVO> getAll(String memberId) {
		return dao.getAll(memberId);
	}
	
	public List<CarOrderVO> getAll(Map<String, String[]> map) {
		return dao.getAll(map);
	}
	
	public Set<CarOrderDetailVO> getRiderPathByDriverPathId(String driverPathId) {
		return dao.getRiderPathByDriverPathId(driverPathId);
	}
	
	public Set<CarOrderDetailVO> getOrderDetailByOrderId(String orderId) {		
		return dao.getOrderDetailByOrderId(orderId);		
	}
}
